// middleware/i18n.js

export default function ({ isHMR, app, store, route, params, error, redirect }) {
  const defaultLocale = app.i18n.fallbackLocale
  if (isHMR) return
  const locale = app.$cookies.get('locale') || defaultLocale
  
  let url = route.fullPath
  if (url.indexOf('/' + defaultLocale) >= 0) {
    url = url.replace(`/${defaultLocale}`, '')
    return redirect(url)
  }
  console.log(locale, defaultLocale, route.fullPath,url.indexOf('/' + defaultLocale), url);
}